﻿<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta content="text/html; charset=UTF-8; X-Content-Type-Options=nosniff" http-equiv="Content-Type" />
<script src="js/smartstream.js"></script>
<style type="text/css">
		.wp_lh_14{line-height:14px; } .wp_lh_18{line-height:18pt; } #homepage_meeting_request_detail_page_win_middle{background-color: #e6e6e6; }.ss_topic_detail_blue_text{color:#00aaff;}.ss_topic_detail_grey_text{color:#a6a6a6;}.wp_ss_hand{cursor:pointer;}.wp_ss_win_border{border:1px solid #eaeaea; }.ss_topic_detail_grey_backgorund{background-color:#f2f2f2;}.wp_ss_topic_detail_hr{color: #e5e5e5;}.wp_ss_topic_detail_input_font_size{color: #bfbfbf}.wp_ml_ne15{margin-left: -15px;}.ss_topic_detail_grey_hr{height:1px;border:none;border-top:1px solid #e5e5e5;}.ss_topic_detail_white_hr{height:1px;border:none;border-top:1px solid white;}
		#ss_topic_detail_comment {display: none;}
		#ss_topic_detail_comment table{height: 80px;background: #F2F2F2;}
		#ss_topic_detail_comment table .k-editable-area{height: 40px; border-color: #efefef;}
		#ss_topic_detail_comment table .k-editor-toolbar a {background: #F2F2F2;}.ss_topic_detail_hand{cursor:pointer;} .wp_mt_ne15{margin-top: -15px}.wp_mt_ne10{margin-top: -10px}.wp_mt_ne25{margin-top: -25px}.ss_topic_detail_comment_reply_line_height{line-height:16px;}
		.ss_topic_detail_html_text_div ul{ margin-left: 12px;}
		.ss_topic_detail_html_text_div ol{ margin-left: 15px;}

		#ss_topic_detail_win_wait_div{position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: black; opacity:.7; z-index: 999999; display: none; }
    	#ss_topic_detail_win_wait_div img{float: left; margin: 300px 0 0 48%; }

   	#ss_topic_detail_select_file .k-upload-files{display: none;}
    #ss_topic_detail_select_file .k-file{display: none;}
    /*kendo upload*/
    #ss_topic_detail_select_file .k-button{min-width:0; width:45px; padding:0;margin:0;}
    #ss_topic_detail_select_file .k-upload-button{background-color: #6cbf43!important;float:right;}
    #ss_topic_detail_select_file .k-upload-button span{height:17px; line-height:17px; font-size:9px;}

    #ss_topic_detail_select_file .k-upload-files{clear:both; min-height:41px;display: none; padding-top:10px;}
    #ss_topic_detail_select_file .k-upload-files li{min-width:42px; max-width:42px; padding:0; border:none; float:left; margin-right:12px; font-size:12px; height:48px;}

    #ss_topic_detail_select_file .k-upload-status{left:16px; top:-3px; line-height:0;}
    #ss_topic_detail_select_file .k-upload-status span{background:url("imgs/delete.png") no-repeat;overflow:visible;}

    #ss_topic_detail_select_file .k-i-pdf{height:40px; width:40px; background:url("imgs/pdfIcon40.png") no-repeat!important; display: block; }
    #ss_topic_detail_select_file .k-i-txt{height:40px; width:40px; background:url("imgs/txt40.png") no-repeat!important; display: block; }
    #ss_topic_detail_select_file .k-i-doc, .k-i-docx {height:40px; width:40px; background:url("imgs/docIcon40.png") no-repeat!important; display: block; }
    #ss_topic_detail_select_file .k-i-xls, .k-i-xlsx {height:40px; width:40px; background:url("imgs/xlsIcon40.png") no-repeat!important; display: block; }
    #ss_topic_detail_select_file .k-i-ppt, .k-i-pptx {height:40px; width:40px; background:url("imgs/ppt40.png") no-repeat!important; display: block; }
    #ss_topic_detail_select_file .k-i-zip{height:40px; width:40px; background:url("imgs/zip40.png") no-repeat!important; display: block; }
    #ss_topic_detail_select_file .k-i-jpeg, .k-i-jpg, .k-i-png, .k-i-gif, .k-i-bmp, .k-i-tiff {height:40px; width:40px; background:url("imgs/img40.png") no-repeat!important; display: block; }

    #ss_topic_detail_select_file .k-upload .k-upload-files li{
    background:transparent !important;
}

	#ss_topic_detail_select_file .k-upload-button-disable{background-color: #f4f4f4!important;float:right;color:#b7b7b7;}
    #smartstream_topic_detail_page_win_wnd_title {width: 580px;}
</style>
<style type="text/css" id="for_ipad"></style>
<div id="ss_topic_detail_win_wait_div">
    <img src="imgs/spinner.gif">
</div>

<div id="smartstream_topic_detail_page_win" class="wp_ss_win_border">
<div id="smartstream_topic_detail_page_iframe">
    
</div>
<div id="smartstream_topic_detail_page_scroll">
	<div id="smartstream_topic_detail_page_win_top"  class="wp_ml_14 wp_mr_14 wp_mt_10">
		<!--<img id="smartstream_topic_detail_page_win_fromImageUrl" data-bind="attr: { src: ss_topic_detail_FromImageUrl},click:onFromNameClick" class="wp_w_20 wp_h_20 left wp_ss_hand" onerror="onDefaultThumbnailWanted(this, 'U20')" />-->
			<div class="wp_w_598 left wp_ml_10 wp_mt_ne3">
				<!--<p class="wp_w_610 wp_h_15"><a id="smartstream_detail_window_fromName" class="wp_dynimac_text left wp_lh_14 wp_fz_12 ss_topic_detail_blue_text wp_ss_hand ss_short_508" data-bind="html: ss_topic_detail_FromName,click:onFromNameClick"></a></p>-->
				<!--<img id="ss_tagicons" src="imgs/icons/tagicon.png" class="left wp_w_10 wp_h_10 wp_mt_4 wp_mr_4"><span class="wp_dynimac_text left wp_mr_10 wp_fz_12 ss_topic_detail_grey_text wp_ss_hand" data-bind="html: ss_topic_detail_Tags" onclick="onTagClick();" style="max-width: 595px;height: auto;" ></span>-->
				<div id="ss_topic_detail_notification_body_div"  class="left wp_w_598">
					<div id="ss_topic_detail_notification_body_p" class="" style="all : none;">
						<p>
		                    <div id="smartstream_detail_window_UpdataText"  class="wp_dynimac_text left wp_fz_12 wp_lh_14 wp_mt_5 wp_w_598 ss_topic_detail_html_text_div"  data-bind="html: ss_topic_detail_from_NotificationBody"></div>
                        </p>
						<div  class="left wp_mt_10 wp_w_598 row"  data-template="ss_topic_datail_attachment_template" data-bind="source:ss_topic_detail_Attachment"></div>
						<div  class="left wp_mt_10 wp_w_598 row"  data-template="ss_topic_datail_imges_template" data-bind="source: ss_topic_detail_Images"></div>

					</div>
				</div>

				<div class="clear"></div>
			</div>
			<div class="clear"></div>
	</div>
    <div id="smartstream_topic_detail_page_win_attachment">
        <div  class="left wp_mt_10 wp_w_598 row"  data-template="ss_topic_datail_iframe_attachment_template" data-bind="source:ss_topic_detail_Attachment"></div>
        <div  class="left wp_mt_10 wp_w_598 row"  data-template="ss_topic_datail_iframe_imges_template" data-bind="source: ss_topic_detail_Images"></div>
    </div>
	<!-- comments panel -->
	<div id="ss_topic_detail_comments" class="wp_mt_10">
		<div class="right wp_fz_12 wp_mr_0 wp_mb_7">
            <div class="right wp_mr_20">
                <span class="left" data-bind="text: ss_topic_detail_modified"></span>
            </div>
		    <div class="clear"></div>
		</div>
		<!-- like buttons panel -->
		<!--
		<div class="right wp_fz_12 wp_mr_0 wp_mb_7">
            <div class="left wp_mr_20">
                <span class="left" data-bind="text: ss_topic_detail_modified"></span>
            </div>
			<div class="left wp_mr_20">
                    <a id="ss_topic_detail_win_subscribed" class="ss_topic_detail_hand" data-bind="click:clickSubscribed,attr: {title: ss_topic_detail_Subscribe_title}">
                        <i data-bind="attr: { class: ss_topic_detail_letter_icon}" ></i>
                    </a>
                </div>
			<div class="left wp_mr_20">
				<i id="smartstream_detail_window_comment_icon" title="Reply" class="main_smartstream_u_8_8 ss_topic_detail_hand"></i>
				<span id="smartstream_detail_window_comment_count" class="wp_dynimac_text">(<span  data-bind="text: ss_topic_detail_CommentsCount"> </span>)</span></div>
            <div class="left " data-bind="visible : expert_display">
                <i id="ss_topic_detail_win_expert" class="main_calendar_s_8_8 smartsteam_clickable" data-bind="click:clickNominateExpert" title="Nominate an Expert"></i>
                <span id="ss_topic_detail_win_expert_cout" class="wp_dynimac_text " data-bind="click:clickExpertsUsers,attr:{class:isExpertClickable}">(<span  data-bind="text:ss_topic_detail_ExpertCount"></span>)</span>
            </div>
			<div class="left wp_mr_20">
				<a id="ss_topic_detail_win_book_mark" class="ss_topic_detail_hand" data-bind="click:clickBookMark" title="Bookmark">
					<i class="" id="ss_topic_detail_bookmark_icon"></i>
				</a>
			</div>
			<div class="left wp_mr_20" title="Share via Email">
				<a id="ss_topic_detail_win_share" class="ss_topic_detail_hand" data-bind="click:onShareEamilClicked">
					<i class="main_calendar_v_8_8"></i>
				</a>
			</div>
			<div class="left wp_mr_20">
				<a id="ss_topic_detail_win_like_notification" class="ss_topic_detail_hand" data-bind="click:clickLikeNotification" >
					<i data-bind="attr: { class: ss_topic_detail_like_icon,title:ss_topic_detail_like_title}"></i>
				</a>
				<span id="ss_topic_detail_win_like_count" class="wp_dynimac_text "  data-bind="click:clickNotiLikeUsersCount,attr:{class:isHasHandClass}">(<span id ="smartstream_detail_window_like_count" data-bind="text: ss_topic_detail_LikeCount"> </span>)</span>
			</div>
		    <div class="clear"></div>
		</div>
		-->
		<!-- like buttons end -->
		<!-- comments grey panel -->
		<!--
		<div  class="left ss_topic_detail_grey_backgorund">

            <div id="ss_topic_detail_win_like_users_left_div" class="wp_fz_12 wp_mt_5">
            	<div class="left wp_ml_15 wp_mt_3 wp_mr_5 wp_h_10 wp_w_10"><i class="main_smartstream_w_8_8 wp_mt_ne2"></i></div>
            	<div class="left" data-template="ss_topic_datail_comments_recent_users" data-bind="source: ss_topic_detail_recent_users_source"> </div><div class="left" data-bind="style: {display: ss_topic_detail_comments_like_detail_other_display}"> <span class="wp_ml_3">and</span> <span class="wp_dynimac_text ss_topic_detail_blue_text ss_topic_detail_hand" data-bind="text:ss_topic_detail_comments_like_detail_LikeCount,click:clickNotiLikeUsersCount"></span> others</div>
            	<div class="clear"></div>
            </div>
            <hr class="ss_topic_detail_white_hr wp_w_658 wp_mt_5 wp_mb_3 left">
            <!-- lw add -->
			<!--
            <input placeholder="&nbsp; Add a Reply" id="ss_topic_detail_add_comment" class="wp_w_628 wp_h_20 wp_fz_12 wp_ml_15 wp_mb_10 wp_ss_topic_detail_input_font_size" />
            <div style="width:95%" class="wp_ml_15" id="ss_topic_detail_comment" >
            	<textarea id="ss_topic_detail_add_comment_editor" class="ss_topic_detail_add_comment_editor_textarea" ></textarea>
            	<div>
            	<div style="position: relative;">
                        <!-- upload attachment -->
						<!--
                        <table id="ss_topic_detail_select_file_table" class="wp_mt_10" style="height:20px!important;">
                            <tr id="ss_topic_detail_select_file" class='wp_h_20'>
                                <td class="left wp_w_576">
                                    <input type="file" name="files" id="ss_topic_detail_select_file_field" autocomplete="off" />
                                </td>
                                <td style="vertical-align:top;" class="wp_h_15 wp_w_58">
                                    <button class="k-button right wp_w_45 wp_h_20 wp_fz_9 wp_mt_7" style="line-height:16px;text-align:center;" data-bind="click:onAttachClick" id="ss_topic_detail_select_file_btn_attach">Attach</button>
                                </td>
                            </tr>
                        </table>
                        <div class="wp_w_628" style="margin-top:10px;">
                            <div id="ss_topic_detail_bottom_icon_expand" class="left wp_mt_5" style="line-height: 20px;">
                                <a class="ss_topic_detail_hand" data-bind="click:onAttachmentPicClick" id="ss_topic_bottom_icon_attachment_pic" style="text-decoration:none;" title="Image">
                                    <i class="main_calendar_k_10_10"></i>
                                </a>

                                <a data-bind="click:onAttachmentFileClick" id="ss_topic_bottom_icon_attachment_file" class="wp_ml_20 ss_topic_detail_hand" style="text-decoration:none;" title="Document">
                                    <i class="main_calendar_m_8_10"></i>
                                </a>
                            </div>

                            <button id="ss_topic_detail_comment_replay_button" class="k-button right wp_mr_2 wp_w_45 wp_h_20 wp_fz_9 wp_mt_5" style="line-height:16px;text-align:center;" data-bind="click:replayComment">Reply</button>
                        </div>
                    </div>

            	   	</div>
            </div>
            <!-- lw add end-->
			<!--
            <div class="left wp_w_640">
            	<div id="ss_topic_detail_comments_panel" class="row"  data-template="ss_topic_datail_comments_template" data-bind="source: ss_topic_detail_comments_source"></div>
            </div>
           <div class="clear"></div>
		</div>
		-->
		<!-- comments grey panel end -->
		<div class="clear"></div>
	</div>
	<!-- comments panel end -->
	<div class="clear"></div>
	<!-- user list window -->
	<div id="ss_topic_detail_user_list_window">
			<div id="ss_topic_detail_user_list_window_content" class="wp_w_384 wp_ml_15 wp_mr_15 wp_mb_10 wp_mt_ne10" data-template="ss_topic_detail_user_list_template" data-bind="source:ss_topic_detail_like_user_list"></div>
	</div>
</div>
</div>


<script id="ss_topic_datail_attachment_template" type="text/x-kendo-template">
	<div class="col_1_4 wp_h_20 wp_mb_10">
		<div class="row wp_h_20 wp_w_130">
		    <div class="col_1_5">
		    	<a class="ss_topic_detail_hand" onclick="FileViewer.load('#: data.url #','#: data.name #','#: data.type#')" target="_blank">
		    		<i class="#: data.typeIcon #"></i>
		    	</a>
		    </div>
		    <div class="col_4_5 wp_fz_12 ss_lh_20 wp_w_100">
		        <div><span title="#: data.name #" class="text-overflow"><a class="ss_topic_detail_hand ss_a"  onclick="FileViewer.load('#: data.url #','#: data.name #','#: data.type#')" target="_blank">#: data.shortname #</a></span></div>
		    </div>
		</div>
	</div>
</script>

<script id="ss_topic_datail_imges_template" type="text/x-kendo-template">
	<div class="col_1_4 wp_h_20 wp_mb_10">
		<div class="row  wp_h_20 wp_w_130">
		    <div class="col_1_5">
		    	<a onclick="FileViewer.load('#: data.bigurl #','#: data.name#','#: data.type#','smartstream_detail_comment_attached_img')" class="ss_topic_detail_hand" target="_blank">
		    		<img src="#: data.smallurl #" class="wp_w_20 wp_h_20" onerror="onDefaultThumbnailWanted(this, 'i')">
		    	</a>
		    </div>
		     <div class="col_4_5 wp_fz_12 ss_lh_20 wp_w_100">
		        <div><span title="#: data.name #" class="text-overflow"><a class="ss_topic_detail_hand ss_a"  onclick="FileViewer.load('#: data.bigurl #','#: data.name#','#: data.type#','smartstream_detail_comment_attached_img')" target="_blank">#: data.shortname #</a></span></div>
		    </div>
		</div>
	</div>
</script>

<script id="ss_topic_datail_iframe_attachment_template" type="text/x-kendo-template">
	<div class="col_1_4 wp_h_20 wp_mb_10">
		<div class="row wp_h_20 wp_w_130">
		    <div class="col_1_5">
		    	<a class="ss_topic_detail_hand" onclick="FileViewer.load('#: data.url #','#: data.name #','#: data.type#')" target="_blank">
		    		<i class="#: data.typeIcon #"></i>
		    	</a>
		    </div>
		    <div class="col_4_5 wp_fz_12 ss_lh_20 wp_w_100">
		        <div><span title="#: data.name #" class="text-overflow"><a class="ss_topic_detail_hand ss_a"  onclick="FileViewer.load('#: data.url #','#: data.name #','#: data.type#')" target="_blank">#: data.shortname #</a></span></div>
		    </div>
		</div>
	</div>
</script>

<script id="ss_topic_datail_iframe_imges_template" type="text/x-kendo-template">
	<div class="col_1_4 wp_h_20 wp_mb_10">
		<div class="row  wp_h_20 wp_w_130">
		    <div class="col_1_5">
		    	<a onclick="FileViewer.load('#: data.bigurl #','#: data.name#','#: data.type#')" class="ss_topic_detail_hand" target="_blank">
		    		<img src="#: data.smallurl #" class="wp_w_20 wp_h_20" onerror="onDefaultThumbnailWanted(this, 'i')">
		    	</a>
		    </div>
		     <div class="col_4_5 wp_fz_12 ss_lh_20 wp_w_100">
		        <div><span title="#: data.name #" class="text-overflow"><a class="ss_topic_detail_hand ss_a"  onclick="FileViewer.load('#: data.bigurl #','#: data.name#','#: data.type#')" target="_blank">#: data.shortname #</a></span></div>
		    </div>
		</div>
	</div>
</script>

<script id="ss_topic_datail_comments_template" type="text/x-kendo-template">
	<div class="row wp_mt_10 wp_ml_15 wp_w_628">
		<div class="row wp_mb_10">
			<img id="smartstream_topic_datail_comment_user_image_#: data.CommentId#" onerror="onDefaultThumbnailWanted(this, 'U20')" data-bind="attr: {src:FromImageUrl},click:onCommentNameClick" class="wp_w_20 wp_h_20 left wp_ss_hand" />
			<div class="left wp_fz_12 wp_w_580 wp_lh_14 wp_ml_10 wp_mt_ne2 ss_topic_detail_blue_text" ><span id="smartstream_topic_datail_comment_from_name_#: data.CommentId#" class="wp_ss_hand" data-bind="text:FromName,click:onCommentNameClick"></span></div>
			<div id="smartstream_topic_datail_posted_comment_#: data.CommentId#" class="left wp_fz_12 wp_w_580 wp_lh_14 wp_ml_10 ss_topic_detail_html_text_div" style="word-wrap:break-word; " data-bind="html: CommentText"></div>
		</div>
		<div class="row right  wp_fz_12 wp_mb_10 wp_mt_ne10">

			<div>
				<span id="smartstream_datail_comment_time_#: data.CommentId #"  class="wp_fz_12 left wp_mr_20">#: data.date #</span>
				# if(data.EnableSocialFeature.Like){#
					<a data-bind="click:clickLikeComment,attr:{title:ss_topic_detail_comment_like_title,class:isHasHandCommentClass}}">
						#if(data.Liked){#
							<i id="smartstream_detail_window_comment_liked_icon_#: data.CommentId #" class="main_smartstream_t_8_8 left wp_mt_2 wp_mr_3"></i>
						#}else{#
							<i id="smartstream_detail_window_comment_like_icon_#: data.CommentId #" class="main_smartstream_w_8_8 left wp_mt_2 wp_mr_3"></i>
						#}#
					</a>
					<span data-bind="click:clickCommentLikeUsersCount,attr:{class:isHasHandCommentLikeClass}">(<span id="smartstream_detail_window_comment_like_count_#: data.CommentId #" class="wp_dynimac_text">#: data.LikesCount #</span>)</span>
				# } else {#
					<a>
					#if(data.Liked){#
						<i id="smartstream_detail_window_comment_liked_icon_#: data.CommentId #" class="main_smartstream_t_8_8 left wp_mt_2 wp_mr_3"></i>
					#}else{#
						<i id="smartstream_detail_window_comment_like_icon_#: data.CommentId #" class="main_smartstream_w_8_8 left wp_mt_2 wp_mr_3"></i>
					#}#
					</a>
					<span>(<span id="smartstream_detail_window_comment_like_count_#: data.CommentId #" class="wp_dynimac_text">#: data.LikesCount #</span>)</span>
				#}#
			</div>

		</div>
		<div class=clear></div>
		<hr class="ss_topic_detail_grey_hr wp_w_670 wp_ml_ne15">
	</div>
</script>


<script id="ss_topic_datail_comments_recent_users" type="text/x-kendo-template">
	<span onclick="homepageProfileWin.user_info_win_create('#:data.UserID#')" class="wp_dynimac_text ss_topic_detail_blue_text ss_topic_detail_hand" > #: data.username #</span>
</script>


<script type="text/x-kendo-template" id="ss_topic_detail_user_list_template">
	<div class="wp_w_162 wp_mb_10 wp_mt_15 wp_w_354">
		<img class="left wp_w_20 wp_h_20 wp_ss_hand" data-bind="attr:{src:UserImageURL},click:onLikeUserClick" onerror="onDefaultThumbnailWanted(this, 'U20')">
		<span class="wp_fz_12 wp_ml_15 wp_h_20 left wp_ss_hand" data-bind="text:UserName,click:onLikeUserClick"></span>
		<div class="clear"></div>
	</div>
</script>



<script type="text/javascript">
	var _loader;
	var ss_topic_detail_notID;
	var ss_topic_detail_notType;
	var ss_topic_detail_tagID;
    var ss_topic_detail_source;
	var ss_topic_detail_creatDate;
	var ss_topic_detail_Text ;
	var ss_topic_detail_comment_offset = "";
	var ssd_SelectedFileName;
	var ssd_SelectedFileContents;
	var ssd_ShareWinFileAppointType;
    var ss_topic_detail_comment_next = true;
	$('#ss_topic_detail_add_comment_editor').kendoEditor({
					        tools: [
					            "bold",
					            "italic",
					            "underline",
					            "strikethrough",
					            "foreColor",
					            "subscript",
					            "superscript",
					            "insertOrderedList",
					            "insertUnorderedList",
					            "justifyLeft",
					            "justifyCenter",
					            "justifyRight",
					            "viewHtml",
                                'createLink'
					        ]
	});
	
	var smartstream_topic_detail_page_win = $('#smartstream_topic_detail_page_win'), ss_topic_detail_page_win_loader = new Workport.Loader(smartstream_topic_detail_page_win), ss_topic_detail_page_win_loaderContent = {position:'center', imgColor:'white', textCSS:{'color':'white'}, boxCSS:{'opacity':'1'}};
	var useragent = Workport.getBrowser();
    var closeCallbackFunction;
    var showExpert = false;
    var enableJoin = false;//when enable join is true...replay button should be disable, and the Lick button in comment should be diable eighter.

	var window_liked_users = $('#community_ss_window_liked_users');
	window_liked_users.kendoWindow({
		width:384,
		height:'auto',
		title:"Liked Users",
		visible:false,
		model:true,
		draggable: false,
		resizable: false,
		modal: true,
		actions:["Close"],
		close:function(){
			window_liked_users.html('');
		}
	});
   
	smartstream_topic_detail_page_win.kendoWindow({
				width:666,
//				height:640,
				title:"Work Port",
				visible:false,
				resizable: false,
				draggable: false,
				modal: true,
				actions:["Close"],
				close:function(){
					$('#ss_topic_detail_add_comment').unbind();
                    var iframeContent = $('#smartstream_topic_detail_page_iframe_content');
                    iframeContent.width(666);
                   // iframeContent.height(0);
					//iframeContent.html("");
                    $('#smartstream_topic_detail_page_win').data("kendoWindow").setOptions({
                        width : 666
                    });
                    if(useragent == 'ipad'){
                    	$('#smartstream_topic_detail_page_scroll').css('margin-left',0)
                    }else{
                    $('#smartstream_topic_detail_page_scroll').parent().css('margin-left',0);
                    }

					if($("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip'))
							$("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip').destroy();

					$('#ss_topic_detail_select_file_name').remove();

					if($("#ss_topic_detail_add_comment_editor").data("kendoEditor")!=null){
						$("#ss_topic_detail_add_comment_editor").data("kendoEditor").value("");
					}
				    $('#ss_topic_detail_add_comment').show();
					$('.ss_topic_detail_white_hr').addClass('wp_mb_10');
					$('#ss_topic_detail_comment').hide();
//					$('#ss_topic_detail_comments_panel').css("height","320");


					ss_topic_detail_viewModel.set("ss_topic_detail_FromName","");
					ss_topic_detail_viewModel.set("ss_topic_detail_from_NotificationBody","");

					ss_topic_detail_viewModel.set("ss_topic_detail_Tags","");
					ss_topic_detail_viewModel.set("letter_display",false);
					ss_topic_detail_viewModel.set("comment_display",false);
					ss_topic_detail_viewModel.set("bookMark_display",false);
					ss_topic_detail_viewModel.set("share_display",false);
					ss_topic_detail_viewModel.set("like_display",false);
                    ss_topic_detail_viewModel.set('expert_display', false);
                    ss_topic_detail_viewModel.set('expert_enable', false);
					ss_topic_detail_viewModel.set("ss_topic_detail_Attachment",[]);
					ss_topic_detail_viewModel.set("ss_topic_detail_Images",[]);
					ss_topic_detail_viewModel.set("ss_topic_detail_AdditionalData","");
					ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",[]);
					ss_topic_detail_viewModel.set("ss_topic_detail_recent_users_source",[]);
					//ss_topic_detail_viewModel.set("ss_topic_detail_recent_users_source","");
					ss_topic_detail_viewModel.set("ss_topic_detail_modified","");
					ss_topic_detail_viewModel.set("ss_topic_detail_FromImageUrl","");
					ss_topic_detail_viewModel.set("defaultUserImage","");
					var wp_win = $("#smartstream_topic_detail_page_win").data("kendoWindow");
					var window_title_bar = wp_win.wrapper.find('.k-window-title');
					window_title_bar.html("");
//					$('#ss_topic_detail_comments_panel').slimScroll().unbind('slimscroll');

					//SmartStream.refreshListView(true); //20140611
					$('#smartstream_topic_detail_page_iframe').empty();
					$('#smartstream_topic_detail_page_iframe').html("");
					$('#smartstream_topic_detail_page_iframe').append('<iframe id="smartstream_topic_detail_page_iframe_content" src="" style="width: 666px;height:0px" frameborder="0"></iframe>');
					document.getElementById('smartstream_topic_detail_page_iframe_content').onload = function() {
						updateScrollHeight();
					};
                    if (closeCallbackFunction) {
                        closeCallbackFunction(ss_topic_detail_notID,ss_topic_detail_notType,ss_topic_detail_tagID,ss_topic_detail_source);
                    }
                    if(useragent == 'ipad'){
	                    $('body').unbind('touchmove');
	                    smartstream_topic_detail_page_win.unbind('touchmove');
	                }
                    return;
				},
				open:function(){

					if(useragent == 'ipad'){
                    	$('body').bind('touchmove',function(event){event.preventDefault()});
	                    smartstream_topic_detail_page_win.bind('touchmove',function(event){event.stopPropagation()});
	                }
				}
    });
	
	
	function closeNotificationWindow(){
		smartstream_topic_detail_page_win.data("kendoWindow").close();
	}
	
	var ss_topic_detail_viewModel = kendo.observable({
				ss_topic_detail_FromName:"",
				ss_topic_detail_from_NotificationBody:"",
				ss_topic_detail_Tags:"",
				letter_display:false,
				comment_display:false,
        		expert_display : false,
        		expert_enable : false,
				bookMark_display:false,
				share_display:false,
				like_display:false,
				ss_topic_detail_Attachment:[],
				ss_topic_detail_Images:[],
				ss_topic_detail_AdditionalData:"",
				ss_topic_detail_comments_source:[],
				//ss_topic_detail_comments_source:"",
				ss_topic_detail_recent_users_source:[],
				ss_topic_detail_like_user_list:[],
				NotificationType:"",
                hasIFrame:false,
				isHasHandClass: function(e) {
					if(ss_topic_detail_viewModel.get("ss_topic_detail_LikeCount")>0 && ss_topic_detail_viewModel.get('like_display'))
			            return "ss_topic_detail_hand";
			        else
			            return "";
				},
                isExpertClickable: function(e) {
                    if (ss_topic_detail_viewModel.get('ss_topic_detail_ExpertCount') > 0) {
                        return "ss_topic_detail_hand wp_dynimac_text wp_mr_20";
                    } else {
                        return 'wp_dynimac_text wp_mr_20';
                    }
                },
                isHasHandCommentClass : function (e) {
                  if (enableJoin) {
                      return "";
                  } else {
                      return "ss_topic_detail_hand";
                  }
                },
				isHasHandCommentLikeClass:function(e){
					//sslog(e);
                    if (enableJoin) {
                        return "";
                    }else if(e.LikesCount>0)
			            return "ss_topic_detail_hand";
			        else {
                        return "";
                    }
				},
				getMailhref: function(e) {
                    var retValue = "mailto:?subject="+e.NotificationTitle+"&body="+encodeURI(e.NotificationBody);
			        return retValue;
			    },
				onLikeUserClick:function(e){homepageProfileWin.user_info_win_create(e.data.UserID);},
				replayComment:function(e){
					if ($("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip'))
						$("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip').destroy();

					var comment = $("#ss_topic_detail_add_comment_editor").data("kendoEditor").value();
					ss_topic_detail_page_win_loader.setContent(smartstream_topic_detail_page_win, ss_topic_detail_page_win_loaderContent);
					comment = comment.replace(new RegExp("&nbsp;","g")," ").trim();
					var commentRep = comment.replace(new RegExp(" ","g"),"");
					commentRep = commentRep.replace(new RegExp("<p>","g"),"");
					commentRep = commentRep.replace(new RegExp("</p>","g"),"");
			        if (Workport.utils.getRealLength(comment)==0) {
						$("#ss_topic_detail_comment").find(".k-editable-area").kendoTooltip({
							content: 'Please input the comment text.' ,
							position: "right",
							autoHide: true,
							hide: function() {
			                    $("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip').destroy();
			                }
						});
					 	$("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip').show();


					}else if (Workport.utils.getRealLength(comment) > 20000) {
						$("#ss_topic_detail_comment").find(".k-editable-area").kendoTooltip({
							content: 'The length of comment must be less than 20000.' ,
							position: "right",
							autoHide: true,
							hide: function() {
			                    $("#ss_topic_detail_comment").find(".k-editable-area").destroy();
			                }
						});
					 	$("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip').show();
					}else{
						if($("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip'))
							$("#ss_topic_detail_comment").find(".k-editable-area").data('kendoTooltip').destroy();
			            var selectFileNameInput = $("#ss_topic_detail_select_file_name"), attachBtn = $("#ss_topic_detail_select_file_btn_attach");
			            //$("#ss_topic_detail_comment_replay_button").addClass("k-state-disabled");
						//e.target.disabled = true;
			            if (selectFileNameInput.val()) {
			            	Workport.utils.alertMsg('', "The browsed content is not attached to the post. Click 'Yes' to post with attachment or 'No' to post without attachment.", 
	                            [
	                                {
	                                    name: 'No',
	                                    action: function () {
	                                        selectFileNameInput.val("");
	                                        attachBtn.addClass("k-state-disabled");
	                                        ss_topic_detail_viewModel.uploadData(comment, false);
	                                    }
	                                },{
	                                    name: 'Yes',
	                                    class: 'btn yes',
	                                    action: function () {
	                                        ss_topic_detail_page_win_loader.show();
	                                        var timer;
	                                        ss_topic_detail_viewModel.onAttachClick();
	                                        timer = setTimeout(function () {
	                                            if (ssd_SelectedFileContents.length > 0) {
	                                                clearTimeout(timer);
	                                                ss_topic_detail_viewModel.uploadData(comment, true);
	                                            }
	                                        }, 1000);
	                                    }
	                                }
	                            ]
	                        );
			            } else {
			            	ss_topic_detail_viewModel.uploadData(comment, false);
			            }
					}
		    	},
		    	uploadData: function (comment, loaderFlag) {
		    		var fileContent, fileSuffix, types = ['jpeg','jpg','gif','bmp', 'png','tiff','tif','pdf','docx','doc','pptx','ppt','xlsx','xls','txt','zip'], attachContents = [], imageContents = [], targetId;
		    		
		    		for (var i = 0; i < ssd_SelectedFileName.length; i++) {
		                fileContent = new Object();

		                fileContent.AttachmentName = ssd_SelectedFileName[i].name.substr(0, ssd_SelectedFileName[i].name.lastIndexOf("."));
		                fileContent.Attachmentbytes = ssd_SelectedFileContents[i];

		                fileSuffix = ssd_SelectedFileName[i].name;
		                fileSuffix = fileSuffix.substr(fileSuffix.lastIndexOf(".") + 1);
		                $.inArray(fileSuffix, types) > -1 ? fileContent.AttachmentType = fileSuffix : null;
		                ssd_SelectedFileName[i].type.match(/image.*/) ? imageContents.push(fileContent) : attachContents.push(fileContent);
		            }

					if(isUserType(ss_topic_detail_viewModel.get("NotificationType")))
						targetId = ss_topic_detail_viewModel.get("NotificationFromID");
					else
						targetId = ss_topic_detail_viewModel.get("NotificationToId");
					if (!loaderFlag) {
						ss_topic_detail_page_win_loader.show();
					}
					if (imageContents.length > 0 || attachContents.length > 0) {
			            var data = {
						    //comment
						    "id":ss_topic_detail_viewModel.get("NotificationId"),//Notification id for which the comments belongs/  parent notification ID
						    "type": ss_topic_detail_viewModel.get("NotificationType"),//U for User to user | C for Community post
						    "text4Comment": comment,
						    "targetId4Comment": ss_topic_detail_viewModel.get("ToID"),//edata.ToId,//user id or Community id
							"fromId" : ss_topic_detail_viewModel.get("NotificationFromID"),
						    //update
                            //api is lack of "notificationbody" which is a html code. So the body will lose its style.
                            //when add the notificationbody, the problem will be solved.
//							    "text4Update":ss_topic_detail_viewModel.get("ss_topic_detail_from_NotificationBody"),
                            "text4Update":ss_topic_detail_Text,
						    "targetId4Update":targetId,
						    "status": "", //leave it empty
						    "subEntity": "Update",//edata.Subentity,//Take sub entity ktype from the parent notification. Subentity for notification/update is: 12
						    //"NotificationText": "",// leave it empty
						    "title": ss_topic_detail_viewModel.get('NotificationTitle'),// leave it empty
						    "tags": ss_topic_detail_viewModel.get('ss_topic_detail_Tags'),//"",// leave it empty
						    "additionalData":"",// leave it empty
						    "entityId": "1",//edata.EntityId,//Take it from the parent notification. Entity Id of the Notification (1-Update)
						    "url": '',// leave it empty
						    "broadcast": "",// leave it empty
						    "attachments": attachContents,
						    "images": imageContents,
							"AtMentionedUsers" : Workport.AtWho.getAtIds(comment)
						};
			            Workport.StreamAPI.addCommentWithAttach(function(_c){
			            	//$("#ss_topic_detail_comment_replay_button").removeClass("k-state-disabled");
							//e.target.disabled = false;
			                if(_c == null){
			                    Workport.utils.alertMsg("", "network error", function(_data){
			                    	$("#ss_topic_detail_comment_replay_button").removeClass("k-state-disabled");
									$("#ss_topic_detail_comment_replay_button").attr("disabled",false);
			                    });
			                    ss_topic_detail_page_win_loader.hide();

			                    return;
			                }
			                if (_c.ResponseCode != "WP1008") {
			                    Workport.utils.alertMsg("", _c.ResponseMessage, function(_data){
			                    	$("#ss_topic_detail_comment_replay_button").removeClass("k-state-disabled");
									$("#ss_topic_detail_comment_replay_button").attr("disabled",false);
			                    });
			                    ss_topic_detail_page_win_loader.hide();

			                    return;
			                }
			                getDetailInfo(this,true,ss_topic_detail_source ? ss_topic_detail_source : "smartstream");
			            },data);
			        }else {
			        	var data = {
							id:ss_topic_detail_viewModel.get("NotificationId"),
							type: ss_topic_detail_viewModel.get("NotificationType"),
							text: comment,
							AtMentionedUsers : Workport.AtWho.getAtIds(comment),
							fromId : ss_topic_detail_viewModel.get("NotificationFromID"),
							targetId: ss_topic_detail_viewModel.get("ToID")
						};
				        Workport.StreamAPI.postComment(function(_d,_c){
				        	// ss_topic_detail_page_win_loader.hide();
				            if (_d.ResponseCode=="WP1008") {
				            	getCommentsInfo(ss_topic_detail_notID,ss_topic_detail_tagID,ss_topic_detail_notType);
				            } else {
				                Workport.utils.alertMsg("", _d.ResponseMessage, function(_data){
				                	$("#ss_topic_detail_comment_replay_button").removeClass("k-state-disabled");
									$("#ss_topic_detail_comment_replay_button").attr("disabled",false);
				                });
				                ss_topic_detail_page_win_loader.hide();
				            }
				        },data);
			        }
		    	},
		    	onAttachmentPicClick: function (e) {
		            if ($($(e.currentTarget).closest("div").find("i")[0]).hasClass("header_win_e_10_10")) {
		                return;
		            } else {
                		ssd_ShareWinFileAppointType = "bmp, gif, jpg, jpeg, png, tif, tiff";

		                $($(e.currentTarget).closest("div").find("i")[0]).toggleClass("main_calendar_k_10_10 header_win_e_10_10");
		                $(e.currentTarget).toggleClass("ss_share_win_detail_arrow ss_topic_detail_hand");

		                if ($($(e.currentTarget).closest("div").find("i")[1]).hasClass("header_win_f_10_10")) {
		                    $($(e.currentTarget).closest("div").find("i")[1]).toggleClass("main_calendar_m_8_10 header_win_f_10_10");
		                    $($(e.currentTarget).closest("div").find("a")[1]).toggleClass("ss_share_win_detail_arrow ss_topic_detail_hand");
		                }
		            }

		            if ($('#ss_topic_detail_select_file_table').is(':hidden')) {
		                $("#ss_topic_detail_select_file_table").show();
		                $("#ss_topic_detail_select_file_name").show();
		            }
                    updateScrollHeight();
					if(ss_topic_detail_notType == 'U'){
						Workport.AtWho.atKendoEditor($("#ss_topic_detail_add_comment_editor").data("kendoEditor"), 'U');
					} else {
						_loader = new Workport.Loader($('#ss_topic_detail_comments'),{position:'center',imgCSS:{'margin-top': '0px'},text:'Loading',imgColor:'black',hasMask:false,textCSS:{'color':'black'}});
						_loader.show();
						Workport.StreamAPI.getMentionUsers(function(_d,_c){
							_loader.hide();
							WP_MENTION_COMM = _d.Users;
							Workport.AtWho.atKendoEditor($("#ss_topic_detail_add_comment_editor").data("kendoEditor"), 'C');
						},{targetID: ss_topic_detail_tagID,type:"C"});
					}
		        },
		        onFromNameClick: function(e) {
		            homepageProfileWin.user_info_win_create(ss_topic_detail_viewModel.get("NotificationFromID"));
		        },
		        onCommentNameClick: function(e) {
		        	homepageProfileWin.user_info_win_create(e.data.FromId);
		        },
		        onAttachmentFileClick: function (e) {
		            if ($($(e.currentTarget).closest("div").find("i")[1]).hasClass("header_win_f_10_10")) {
		                return;
		            } else {
                		ssd_ShareWinFileAppointType = "pdf, doc, docx, ppt, pptx, xls, xlsx, txt, zip";
		                $($(e.currentTarget).closest("div").find("i")[1]).toggleClass("main_calendar_m_8_10 header_win_f_10_10");
		                $(e.currentTarget).toggleClass("ss_share_win_detail_arrow ss_topic_detail_hand");
		                if ($($(e.currentTarget).closest("div").find("i")[0]).hasClass("header_win_e_10_10")) {
		                    $($(e.currentTarget).closest("div").find("i")[0]).toggleClass("main_calendar_k_10_10 header_win_e_10_10");
		                    $($(e.currentTarget).closest("div").find("a")[0]).toggleClass("ss_share_win_detail_arrow ss_topic_detail_hand");
		                }
		            }
		            if ($('#ss_topic_detail_select_file_table').is(':hidden')) {
		                $("#ss_topic_detail_select_file_table").show();
		                $("#ss_topic_detail_select_file_name").show();
		            }
                    updateScrollHeight();
					if(ss_topic_detail_notType == 'U'){
						Workport.AtWho.atKendoEditor($("#ss_topic_detail_add_comment_editor").data("kendoEditor"), 'U');
					} else {
						_loader = new Workport.Loader($('#ss_topic_detail_comments'),{position:'center',imgCSS:{'margin-top': '0px'},text:'Loading',imgColor:'black',hasMask:false,textCSS:{'color':'black'}});
						_loader.show();
						Workport.StreamAPI.getMentionUsers(function(_d,_c){
							_loader.hide();
							WP_MENTION_COMM = _d.Users;
							Workport.AtWho.atKendoEditor($("#ss_topic_detail_add_comment_editor").data("kendoEditor"), 'C');
						},{targetID: ss_topic_detail_tagID,type:"C"});
					}
		        },
		        onAttachClick: function (e) {
		            if ($("#ss_topic_detail_select_file_name").val() == "") {
		                return;
		            }
		            $('.k-upload-files').show();
		            $("#ss_topic_detail_select_file_name").val("");
		            var shareWinFileSize = ssd_SelectedFileName.length;//=$("#ss_topic_detail_select_file_table ul li").size() - 1;
		            var shareWinMaxAttechmentCount = 9; ////Can choose the number of attachments, Starting from 0
		            // button disabled, Can't choose the file
		            if (shareWinFileSize == shareWinMaxAttechmentCount) {
		                // $(".k-upload-sync").addClass("k-state-doors");
		                $('#ss_topic_detail_select_file').find('input:file:last').prop('disabled', true);
		                $("#ss_topic_detail_select_file input:file:last").css("cursor","default");
		                $("#ss_topic_detail_select_file div:eq(1)").addClass("k-upload-button-disable");
		            }
		            //ss_temp = $("#ss_topic_select_file_"" ul li:last");
		            $("#ss_topic_detail_select_file_table ul li:last").show();
		            //get attachment base64 encode
		            var shareWinFileReader = new FileReader();
		            shareWinFileReader.onload = function(e) {
            			ssd_SelectedFileContents.push(e.target.result.replace(/^.*?,/,''));
                        updateScrollHeight();
		            }
		            var shareWinSelectedAttechment = $('#ss_topic_detail_select_file_table').find('.k-file:last').data().fileNames[0].rawFile;
		            shareWinFileReader.readAsDataURL(shareWinSelectedAttechment);
		            ssd_SelectedFileName.push(shareWinSelectedAttechment);
		            $("#ss_topic_detail_select_file_btn_attach").addClass("k-state-disabled");
					$("#ss_topic_detail_select_file ul li:last").find('.k-upload-action').attr("id","smartstream_datail_comment_remove_icon_"+shareWinSelectedAttechment.name);
		        },
		    	clickSubscribed:function(e){
                    if (!ss_topic_detail_viewModel.get('letter_display')) {
                        return;
                    }
		            var isSub = "0";
				    if(ss_topic_detail_viewModel.get("isSubscribe"))
				        isSub = "1";
				    var data ={
                        notificationId: ss_topic_detail_viewModel.get("NotificationId"),
                        targetId : ss_topic_detail_viewModel.get("NotificationType").toLowerCase()=='c'?ss_topic_detail_viewModel.get("CommunityId"):ss_topic_detail_viewModel.get("NotificationFromID"),
                        notificationType : ss_topic_detail_viewModel.get("NotificationType"),
				        action: isSub
				    };
                    Workport.StreamAPI.subscriptionMail(function(_d,_c){
                        if(_d.ResponseCode=="WP1008"){
                            if(ss_topic_detail_viewModel.get("isSubscribe")){
                                ss_topic_detail_viewModel.set("ss_topic_detail_letter_icon","main_calendar_u_8_8");
                                ss_topic_detail_viewModel.set("ss_topic_detail_Subscribe_title","Receive Mail Alerts");
                                ss_topic_detail_viewModel.set("isSubscribe",false);
                            }else{
                                ss_topic_detail_viewModel.set("ss_topic_detail_letter_icon","main_calendar_t_8_8");
                                ss_topic_detail_viewModel.set("ss_topic_detail_Subscribe_title","Stop Mail Alerts");
                                ss_topic_detail_viewModel.set("isSubscribe",true);
                            }
                        }else{
                            Workport.utils.alertMsg("", _d.ResponseMessage, function(_data){});
                        }
                    },data);
		    	},
		    	clickBookMark:function(e){
                    if (!ss_topic_detail_viewModel.get('bookMark_display')) {
                        return;
                    }
		    		var isMark ;
				    if($(e.currentTarget).children("i").hasClass('main_smartstream_ab_8_8')){
				    	isMark = "1" ;
				    }else{
				    	isMark = "0" ;
				    }
		    		var data ={
					    NotificationId: ss_topic_detail_viewModel.get("NotificationId"),
					    CommunityId: ss_topic_detail_viewModel.get("NotificationToId"),
					    ActionType: isMark,
					    NotificationType: ss_topic_detail_viewModel.get("NotificationType")
 					};
 					Workport.Communication.post('Stream/Bookmark',function(status,result){
						if(result&&result.ResponseCode!="WP2003"){
				    		$(e.currentTarget).children("i").toggleClass("main_smartstream_ab_8_8");
				        	$(e.currentTarget).children("i").toggleClass("main_smartstream_aa_8_8");
                            $('#ss_topic_detail_win_book_mark').attr('title', isMark == '0'?'Unbookmark':'Bookmark');
				    	}else{
				    		if(result&&result.ResponseMessage){
				    			Workport.utils.alertMsg("", result.ResponseMessage, function(_data){});
				    		}else{
				    			Workport.utils.alertMsg("", "Bookmark  response is null.", function(_data){});
				    		}
				    	}
					},data);
		    	},
				onShareEamilClicked : function () {
					if (!ss_topic_detail_viewModel.get('share_display')) {
                        return;
                    }
					share_email_win.open(ss_topic_detail_viewModel.get('NotificationTitle'),ss_topic_detail_Text);
				},
                clickNominateExpert : function (e) {
                    if (!ss_topic_detail_viewModel.get('expert_enable')) {
                        return;
                    }
                    var self = this;
                    var cb = function () {
                        getDetailInfo(self, true,ss_topic_detail_source ? ss_topic_detail_source : "community");
                    };
                    commSelectStaffWinFunc.open(ss_topic_detail_notID, ss_topic_detail_tagID, ss_topic_detail_viewModel.get('ss_topic_detail_Tags'), cb);
                },
                clickExpertsUsers : function (e) {
                    if (!ss_topic_detail_viewModel.get('expert_enable')) {
                        return;
                    }
                    if (ss_topic_detail_viewModel.get('ss_topic_detail_ExpertCount') <= 0) {
                        return;
                    }
                    Workport.CommunityAPI.getExport(function (data) {
                        if (data && data.Users) {
                            var data = data.Users;
                            var tmlt = kendo.template($('#community_ss_window_tmpl_expert_users').html(), {useWithBlock: false});
                            var arr = [];
                            $.map(data, function (_data) {
                                arr.push(tmlt(_data));
                            });

                            window_liked_users.html(arr.join(''));
                            arr.length = 0;
                            window_liked_users.data('kendoWindow').title('Experts');
                            window_liked_users.data('kendoWindow').center();
                            window_liked_users.data('kendoWindow').open();
                            window_liked_users.prev().find(".k-i-close").attr("id","community_liked_users_close_button");
                        }
                    },{pagePosition : 0, pageSize: 200, notificationType:ss_topic_detail_notType,targetId:ss_topic_detail_tagID, notificationId:ss_topic_detail_notID});
                },
		    	clickLikeNotification:function(e){
					if (!ss_topic_detail_viewModel.get('like_display')) {
                        return;
                    }
					var putdata ={
					  TargetId: ss_topic_detail_viewModel.get("NotificationToId"),
					  NotificationId: ss_topic_detail_viewModel.get("NotificationId"),
					  NotificationFromID: ss_topic_detail_viewModel.get("NotificationFromID"),
					  CommentId: "",
					  CommentedByID: "",
					  NotificationType: ss_topic_detail_viewModel.get("NotificationType")
					};
					var currentTar=$(e.currentTarget).children("i");
					postLikeMessage(putdata,ss_topic_detail_like_notification_callback,currentTar);

		    	},
		    	clickNotiLikeUsersCount:function(e){
                    if (!ss_topic_detail_viewModel.get('like_display')) {
                        return;
                    }
		    		if(ss_topic_detail_viewModel.get("ss_topic_detail_LikeCount")>0){
		    				//$("#ss_topic_detail_win_wait_div").show();
			    			var likeUsersData={ ps: 10, pn: 0};
			    			Workport.Communication.get( Workport.utils.obj2url("Stream/"+ss_topic_detail_viewModel.get("NotificationId")+"/Like",likeUsersData),function(status,result){
			    			//$("#ss_topic_detail_win_wait_div").hide();
							if(result){
								if(result.length>0&&result[0].LikedUsersDetails){
									if(result[0].LikedUsersDetails.length>0){
										var data=result[0].LikedUsersDetails;
										ss_topic_detail_viewModel.set("ss_topic_detail_like_user_list",data);
										var ss_topic_detail_user_list_win = $('#ss_topic_detail_user_list_window');
										ss_topic_detail_user_list_win.kendoWindow({
											width:384,
											height:40,
											title:"Liked Users",
											visible:false,
											model:true,
											draggable: false,
											resizable: false,
											modal: true,
											actions:["Close"],
											close:function(){
												ss_topic_detail_viewModel.set("ss_topic_detail_like_user_list",[]);
											}
										});
										// add Linked Users window close button id.
										$("#ss_topic_detail_user_list_window").prev().find("span.k-i-close").attr("id","smartstream_liked_users_close_button");
										ss_topic_detail_user_list_win.data("kendoWindow").center();
										ss_topic_detail_user_list_win.data("kendoWindow").open();
                                        ss_topic_detail_user_list_win.prev().find(".k-i-close").attr("id","ss_topic_detail_user_list_window_close");
										var height=$("#ss_topic_detail_user_list_window_content").height();

										if(data.length>8){
											if(useragent == 'ipad'){
												$('#ss_topic_detail_user_list_window_content').css('height',height);
												$('#ss_topic_detail_user_list_window_content').css('width','180px');
												$('#ss_topic_detail_user_list_window_content').css('overflow-x','hidden');
												$('#ss_topic_detail_user_list_window_content').css('overflow-y','scroll');
											}else{
											$('#ss_topic_detail_user_list_window_content').slimScroll({
												 		height: height+'px',
												 		width:'180px',
                                                        wheelStep : 20,
														disableFadeOut:true
											});
											}
											$('#ss_topic_detail_user_list_window_content').css("margin-top","10px");
										}else if(data.length==1){
											var thisHeight=height+20+"px";
											$('#ss_topic_detail_user_list_window').css("height",thisHeight);
										}else{
											var thisHeight=height+20+"px";
											$('#ss_topic_detail_user_list_window').css("height",thisHeight);

										}
									}

								}else{
									Workport.utils.alertMsg("", "LikedUsersDetails is null.", function(_data){});
								}

							}else{
								Workport.utils.alertMsg("", "Liked users list response is Null.", function(_data){});
							}
						});
		    		}
		    	},
		    	clickCommentLikeUsersCount:function(e){
		    		if(e.data.LikesCount>0){
		    				//$("#ss_topic_detail_win_wait_div").show();
	    					var likeUsersData={ ps: 10, pn: 0};
							Workport.Communication.get( Workport.utils.obj2url("Stream/"+e.data.CommentId+"/Like",likeUsersData),function(status,result){
								//$("#ss_topic_detail_win_wait_div").hide();
								if(result){
									if(result.length>0&&result[0].LikedUsersDetails){
										if(result[0].LikedUsersDetails.length>0){
											var data=result[0].LikedUsersDetails;
											ss_topic_detail_viewModel.set("ss_topic_detail_like_user_list",data);
											var ss_topic_detail_user_list_win = $('#ss_topic_detail_user_list_window');
											ss_topic_detail_user_list_win.kendoWindow({
												width:384,
												height:40,
												title:"Liked Users",
												visible:false,
												draggable: false,
												model:true,
												resizable: false,
												modal: true,
												actions:["Close"],
												close:function(){
													ss_topic_detail_viewModel.set("ss_topic_detail_like_user_list",[]);
												}
											});
											ss_topic_detail_user_list_win.data("kendoWindow").center();
											ss_topic_detail_user_list_win.data("kendoWindow").open();
                                            ss_topic_detail_user_list_win.prev().find(".k-i-close").attr("id","ss_topic_detail_user_list_window_close");
											var height=$("#ss_topic_detail_user_list_window_content").height();
											//ss_topic_detail_user_list_win.data("kendoWindow").setOptions({height: $("#ss_topic_detail_user_list_window_content").height()+20});
											if(data.length>8){
												if(useragent == 'ipad'){
												$('#ss_topic_detail_user_list_window_content').css('height',height);
												$('#ss_topic_detail_user_list_window_content').css('width','180px');
												$('#ss_topic_detail_user_list_window_content').css('overflow-x','hidden');
												$('#ss_topic_detail_user_list_window_content').css('overflow-y','scroll');
												}else{
												$('#ss_topic_detail_user_list_window_content').slimScroll({
													 		height: height+'px',
													 		width:'180px',
															disableFadeOut:true
												});
												}											
												$('#ss_topic_detail_user_list_window_content').css("margin-top","10px");
											}else if(data.length==1){
												var thisHeight=height+20+"px";
												$('#ss_topic_detail_user_list_window').css("height",thisHeight);
											}else{
												var thisHeight=height+20+"px";
												$('#ss_topic_detail_user_list_window').css("height",thisHeight);
											}
										}
									}else{
										Workport.utils.alertMsg("", "LikedUsersDetails is null.", function(_data){});
									}
								}else{
									Workport.utils.alertMsg("", "Liked users list response is Null.", function(_data){});
								}
							});
		    		}
		    	},
		    	clickLikeComment:function(e){
					var putdata ={
					  TargetId: ss_topic_detail_viewModel.get("NotificationToId"),
					  NotificationId: ss_topic_detail_viewModel.get("NotificationId"),
					  NotificationFromID: ss_topic_detail_viewModel.get("NotificationFromID"),
					  CommentId: e.data.CommentId,
					  CommentedByID: e.data.FromId,
					  NotificationType: ss_topic_detail_viewModel.get("NotificationType")
					};
					postLikeMessage(putdata,ss_topic_detail_like_comment_callback);
		    	},
		    	ss_topic_detail_comment_like_title:function(e){
		    		if(e.Liked){
		    			return "You have Liked this";
		    		}else
		    		{
		    			return "Like this";
		    		}
		    	}
	});
	kendo.bind($("#smartstream_topic_detail_page_win"), ss_topic_detail_viewModel);
	function setDefaultImage(){
		var type=ss_topic_detail_viewModel.get("NotificationType");
		if (type == 'c' || type == 'C') {
			ss_topic_detail_viewModel.set("ss_topic_detail_FromImageUrl",'imgs/CommunityDefault.png');
		}
		else if (type == 'u' || type == 'U') {
			 ss_topic_detail_viewModel.set("ss_topic_detail_FromImageUrl", 'imgs/UserDefault.png');
		}
		else if (type == 'i' || type == 'I') {
			 ss_topic_detail_viewModel.set("ss_topic_detail_FromImageUrl", 'imgs/img20.png');
		}
		else {
			//sslog('setDefaultImage: wrong notification type:' + type);
		}
	}

	function setDefaultCommentImage(e,e2){
		//sslog(e);
		var type=e;//ss_topic_detail_viewModel.get("NotificationType");
	    if (type == 'c' || type == 'C') {
	        e.src='imgs/CommunityDefault.png';
	    }
	    else if (type == 'u' || type == 'U') {
	    	e.src='imgs/UserDefault.png';
	    }
	    else if (type == 'i' || type == 'I') {
	    	e.src='imgs/img20.png';
	    }
	  	else {
	       // sslog('setDefaultCommentImage: wrong notification type:' + type);
	    }
	}

	function getCommentsInfo(notID,tagID,notType, CB){
		var view_model = this;
        ss_topic_detail_comment_next = false;
		Workport.Communication.get(Workport.utils.obj2url("Stream/"+notID+"/Comment",{ tid: tagID, ps: 10, offset:"",ntype:notType}),function(status,result){
			ss_topic_detail_page_win_loader.hide();
			if(result&&result.comments){
			    ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",addCommentListTimeStamp(result.comments));
			    if(result.comments.length>0){
			    	ss_topic_detail_comment_offset=result.comments[0].LastModifiedDate;
			    }
			    $("#ss_topic_detail_add_comment_editor").data("kendoEditor").value("");
			    $('#ss_topic_detail_add_comment').show();
				$('.ss_topic_detail_white_hr').addClass('wp_mb_10');
				$('#ss_topic_detail_comment').hide();
				if(result&&result.comments.length > 0){
				    ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",addCommentListTimeStamp(result.comments));
				    ss_topic_detail_viewModel.set("ss_topic_detail_CommentsCount",result.comments[0].CommentCount);
			    }else{
			    	ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",[]);
			    	ss_topic_detail_viewModel.set("ss_topic_detail_CommentsCount",0);
			    }
                if (result.ResponseCode == 'WP1005') {
                    ss_topic_detail_comment_next = false;
                } else {
                    ss_topic_detail_comment_next = true;
                }
		    }else{
		    	ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",[]);
                ss_topic_detail_comment_next = true;
		    }
            if (CB) {
                CB();
            } else {
                updateScrollHeight();
            }
		});
	}
	
	function getLikeUserInfo(notID, CB){
		var view_model = this;
		var likeUsersData={ ps: 4, pn: 0};
		var _self = this;
		Workport.Communication.get( Workport.utils.obj2url("Stream/"+notID+"/Like",likeUsersData),function(status,result){
			_self.isLiked = false;
			if(result&&result.length>0){
				if(result[0].LikedUsersDetails && result[0].LikedUsersDetails.length > 0){
					$('#ss_topic_detail_win_like_users_left_div').show();
					var recent_users = new Array();
					recent_users.push({"username":result[0].LikedUsersDetails[0].UserName,UserID:result[0].LikedUsersDetails[0].UserID});
					ss_topic_detail_viewModel.set("ss_topic_detail_recent_users_source",recent_users);
					var likeCount = result[0].LikedUsersDetails.length - 1;
					if(result[0].LikedUsersDetails.length<=1){
						ss_topic_detail_viewModel.set("ss_topic_detail_comments_like_detail_other_display","none");
					}else{
						ss_topic_detail_viewModel.set("ss_topic_detail_comments_like_detail_other_display","inline");
						ss_topic_detail_viewModel.set("ss_topic_detail_comments_like_detail_LikeCount",likeCount);	
					}
				}else{
					$('#ss_topic_detail_win_like_users_left_div').hide();
				}
			}
            if (CB) {
                CB();
            } else {
                updateScrollHeight();
            }
		});
	}

	function genAttachment(view_model,this_data){
    	var ss_topic_deatil_attachments_array;
    	if (this_data.Attachments != null && this_data.Attachments.length != 0) {
    		ss_topic_deatil_attachments_array = ss_topic_detail_handle_attachment_url(this_data.Attachments);
    	} else {
    		ss_topic_deatil_attachments_array = [];
    	}
    	var imgsList;
    	if (this_data.Images != null && this_data.Images.length != 0) {
    		imgsList = ss_tipic_detailGetImgUrl(this_data.Images);
    	}else{
    		imgsList = [];
    	}
		view_model.set("ss_topic_detail_Attachment",ss_topic_deatil_attachments_array);
		view_model.set("ss_topic_detail_Images",imgsList);
	}

	function getDetailInfo(view_model1,isRefresh,source){
		var view_model = ss_topic_detail_viewModel;
		var url="Stream/"+ss_topic_detail_notID;
		var data={ ntype: ss_topic_detail_notType, tid: ss_topic_detail_tagID,source:source};
		Workport.Communication.get(Workport.utils.obj2url(url,data),function(status,result){
			// ss_topic_detail_page_win_loader.hide();
			if(result&&result.notification&&result.notification.length>0){
				var this_data=result.notification[0];
				if(ss_topic_detail_notType!=this_data.NotificationText)
					ss_topic_detail_Text = this_data.NotificationText;
				var window_title= this_data.NotificationTitle;
				var window_title_bar = $("#smartstream_topic_detail_page_win").data("kendoWindow").wrapper.find('.k-window-title');
                $("#smartstream_topic_detail_page_win").data("kendoWindow").title(window_title);
//				window_title_bar.html(window_title);
				view_model.set('getMailHref',"mailto:?subject="+window_title+"&body="+ss_topic_detail_Text+"%0d%0aYou can access the post directly from here");
				//wp_win.title(window_title);
				var tagsString;
				if(this_data.Tags!=null){
					tagsString=(this_data.Tags).join(", ");
				}else{
					tagsString="";
				}
				var dtCreatedDate = new Date(this_data.LastModifiedDate);
	        	var dtLastModifiedDate = new Date(this_data.ServerDate);
	        	var iDay = ss_GetDateDiff(dtLastModifiedDate,dtCreatedDate,"day");
	        	var iHour;
	        	var iMinutes;
	        	var iSeconds;
	        	if (iDay == 0) {
	        		iHour = ss_GetDateDiff(dtLastModifiedDate,dtCreatedDate,"hour");
	        		if(iHour==0){
	        			iMinutes=ss_GetDateDiff(dtLastModifiedDate,dtCreatedDate,"minute");
	        			if(iMinutes==0){
	        				iSeconds=ss_GetDateDiff(dtLastModifiedDate,dtCreatedDate,"second");
	        				view_model.set("ss_topic_detail_modified",iSeconds+" second(s) ago");
	        			}else{
	        				view_model.set("ss_topic_detail_modified",iMinutes+" minute(s) ago");
	        			}

	        		}else{
	        			view_model.set("ss_topic_detail_modified",iHour+" hour(s) ago");
	        		}
	        	}else{
	        		view_model.set("ss_topic_detail_modified",iDay+" day(s) ago");
	        	}
				genAttachment(view_model,this_data);

				view_model.set("ss_topic_detail_FromImageUrl",this_data.FromImageUrl);
				var fromName=this_data.FromName;
				if(fromName.length>40){
					fromName=fromName.substring(0,40)+'…';
				}
				view_model.set("ss_topic_detail_FromName",fromName);
				if(tagsString == null || tagsString == ''){
					$('#ss_tagicons').hide();
				} else {
					$('#ss_tagicons').show();
				}
				view_model.set("ss_topic_detail_Tags",tagsString);
				if(this_data.AdditionalData==null||this_data.AdditionalData==""){

					view_model.set("ss_topic_detail_from_NotificationBody",this_data.NotificationBody);
				}else {
					view_model.set("ss_topic_detail_from_NotificationBody",this_data.NotificationBody + this_data.AdditionalData);
				}

				if(this_data.LikesCount!=null&&this_data.LikesCount!=""){
					view_model.set("ss_topic_detail_LikeCount",this_data.LikesCount);
				}else{
					view_model.set("ss_topic_detail_LikeCount",0);
				}

				if(this_data.CommentCount!=null&&this_data.CommentCount!=""){
					view_model.set("ss_topic_detail_CommentsCount",this_data.CommentCount);
				}else{
					view_model.set("ss_topic_detail_CommentsCount",0);
				}

                if (this_data.ExpertsCount) {
                    view_model.set('ss_topic_detail_ExpertCount', this_data.ExpertsCount);
                } else {
                    view_model.set('ss_topic_detail_ExpertCount', 0);
                }
				//button panel icno
				/*
                this_data.EnableSocialFeature.Subscribe = false;
                this_data.EnableSocialFeature.Comment = false;
                this_data.EnableSocialFeature.NominateExpert =false;
                this_data.EnableSocialFeature.BookMark =false;
                this_data.EnableSocialFeature.Share = false;
                this_data.EnableSocialFeature.Like =false;
				*/
				if(this_data.EnableSocialFeature.Subscribe){
					view_model.set("letter_display",true);
                    $('#ss_topic_detail_win_subscribed').addClass('ss_topic_detail_hand');
				}else{
					view_model.set("letter_display",false);
                    $('#ss_topic_detail_win_subscribed').removeClass('ss_topic_detail_hand');
				}
                if(this_data.IsSubscribed){
                    view_model.set("isSubscribe",true);
                    view_model.set("ss_topic_detail_letter_icon","main_calendar_t_8_8");
                    view_model.set("ss_topic_detail_Subscribe_title","Stop Mail Alerts");
                }else{
                    view_model.set("isSubscribe",false);
                    view_model.set("ss_topic_detail_letter_icon","main_calendar_u_8_8");
                    view_model.set("ss_topic_detail_Subscribe_title","Receive Mail Alerts");
                }
				if(this_data.EnableSocialFeature.Comment){
					//view_model.set("comment_display",true);
					$("#ss_topic_detail_add_comment").attr("disabled",false);
					$("#smartstream_detail_window_comment_icon").addClass("ss_topic_detail_hand");
				}else{
					//view_model.set("comment_display",false);
					$("#smartstream_detail_window_comment_icon").removeClass("ss_topic_detail_hand");
					$("#ss_topic_detail_add_comment").attr("disabled",true); 
				}
                if(parseInt(this_data.CommentCount)>0){
                    view_model.set("ss_topic_detail_comment_icon","main_smartstream_u_8_8 wp_mr_20");
                }else{
                    view_model.set("ss_topic_detail_comment_icon","main_smartstream_v_8_8 wp_mr_20");
                }
                if (this_data.ExpertsCount && showExpert) {
                    view_model.set('expert_display', true);
                } else {
                    view_model.set('expert_display', false  );
                }
                if (this_data.EnableSocialFeature.NominateExpert) {
                    view_model.set('expert_enable', true);
                } else {
                    view_model.set('expert_enable', false);
                    $('#ss_topic_detail_win_expert').removeClass('smartsteam_clickable');
                    $('#ss_topic_detail_win_expert_cout').removeClass('ss_topic_detail_hand');
                }
				if(this_data.EnableSocialFeature.BookMark){
					view_model.set("bookMark_display",true);
                    $('#ss_topic_detail_win_book_mark').addClass('ss_topic_detail_hand');
				}else{
					view_model.set("bookMark_display",false);
                    $('#ss_topic_detail_win_book_mark').removeClass('ss_topic_detail_hand');
				}
                if(this_data.IsBookMarked){
                    //view_model.set("ss_topic_detail_bookmark_icon","main_smartstream_ab_8_8 wp_mr_20 wp_mt_3");
                    $("#ss_topic_detail_bookmark_icon").removeClass("main_smartstream_aa_8_8");
                    $("#ss_topic_detail_bookmark_icon").addClass("main_smartstream_ab_8_8");
                    $('#ss_topic_detail_win_book_mark').attr('title', 'Unbookmark');

                }else{
                    //view_model.set("ss_topic_detail_bookmark_icon","main_smartstream_aa_8_8 wp_mr_20 wp_mt_3");
                    $("#ss_topic_detail_bookmark_icon").removeClass("main_smartstream_ab_8_8");
                    $("#ss_topic_detail_bookmark_icon").addClass("main_smartstream_aa_8_8");
                    $('#ss_topic_detail_win_book_mark').attr('title','Bookmark');
                }
				if(this_data.EnableSocialFeature.Share){
					view_model.set("share_display",true);
                    $('#ss_topic_detail_win_share').addClass('ss_topic_detail_hand');
				}else{
					view_model.set("share_display",false);
                    $('#ss_topic_detail_win_share').removeClass('ss_topic_detail_hand');
                    $('#ss_topic_detail_win_share').removeAttr('href');
				}
				if(this_data.EnableSocialFeature.Like){
					view_model.set("like_display",true);
				}else{
					view_model.set("like_display",false);
                    $('#ss_topic_detail_win_like_notification').removeClass('ss_topic_detail_hand');
                    $('#ss_topic_detail_win_like_count').removeClass('ss_topic_detail_hand');
				}
                if(this_data.IsLiked){
                    view_model.set("ss_topic_detail_like_icon","main_smartstream_t_8_8 ");
                    view_model.set("ss_topic_detail_like_title","You have Liked this");
                }else{
                    view_model.set("ss_topic_detail_like_icon","main_smartstream_w_8_8");
                    view_model.set("ss_topic_detail_like_title","Like this");
                }
				//put like parameter
				view_model.set("TargetId",this_data.ToId);
				view_model.set("NotificationId",this_data.NotificationId);
				view_model.set("NotificationFromID",this_data.FromId);
				view_model.set("NotificationType",this_data.NotificationType);
				view_model.set("NotificationToId",this_data.ToId);
                view_model.set("CommunityId", this_data.CommunityId);
                view_model.set("NotificationTitle",this_data.NotificationTitle);
				//is liked
				if(this_data.IsLiked!=null){
					view_model.set("isLiked",this_data.IsLiked);
				}else{
					view_model.set("isLiked",false);
				}
				view_model.set("ToID",ss_topic_detail_tagID);
				view_model.set("notID",ss_topic_detail_notID);
				view_model.set("notType",ss_topic_detail_notType);
				view_model.set("tagID",ss_topic_detail_tagID);
				view_model.set("creatDate",ss_topic_detail_creatDate);
                if (!isRefresh) {
                    smartstream_topic_detail_page_win.data("kendoWindow").open();
                    smartstream_topic_detail_page_win.data("kendoWindow").center();
                }
                getLikeUserInfo(ss_topic_detail_notID, function () {
                    getCommentsInfo(ss_topic_detail_notID,ss_topic_detail_tagID,ss_topic_detail_notType,function(){
                        updateScrollHeight();
                    });
                });
			}else {
				Workport.utils.alertMsg("", "This update has been deleted.", function(_data){
//						SmartStream.refreshListView(true,true);//no cache
				});
			}
		});
	}
	
    function updateScrollHeight () {
        if ($('#smartstream_topic_detail_page_iframe').css('display') != 'none') {
            //for the iframe
            var iframeContent = $('#smartstream_topic_detail_page_iframe_content');
            var screenWidth = $(window).width();
            var isError = false;
            try{
                var w = document.getElementById('smartstream_topic_detail_page_iframe_content').contentWindow.document.body.scrollWidth;
                var h = document.getElementById('smartstream_topic_detail_page_iframe_content').contentWindow.document.body.scrollHeight;
                if (w<=0) { w = -19;}
                if (h<=0) { h = -19;}
                if(w>(screenWidth*0.9)){
                    w=screenWidth*0.9;
                }
                if(h>(Screen.bodyHeight*0.5)){
                    h=Screen.bodyHeight*0.5;
                }
            }catch(e){
                isError = true;
                w=screenWidth*0.9;
                h=Screen.bodyHeight*0.5;
            }
            if (w < 646) {
                w = 646;
            }
            console.log('w='+w+',h='+h+',err='+isError);
            iframeContent.width(w + 20);
            iframeContent.height(h + 20);
            $('#smartstream_topic_detail_page_win').data("kendoWindow").setOptions({
                width : w + 20
            });
            //center the comment
            w+=20;
            if(useragent == 'ipad'){
            	$('#smartstream_topic_detail_page_scroll').css('margin-left',w/2 - 333);
            }else{
            	$('#smartstream_topic_detail_page_scroll').parent().css('margin-left',w/2 - 333);
            }
        }

        //normal
        var height1 = parseInt($('#smartstream_topic_detail_page_win_top').css('height')) + 10;
        var height2 = parseInt($('#ss_topic_detail_comments').css('height')) + 10;
        var height3 = parseInt($('#smartstream_topic_detail_page_iframe').css('height'))+10;
        if (height3 <= 10) {
            height3 = 0;
        }
        var realH = height1 + height2 + height3;
        var scrollH = height1 + height2;
        if (scrollH <= 20) {
            realH = height3;
            scrollH = 0;
        }
        if (realH > Screen.bodyHeight-20) {
            realH = Screen.bodyHeight-20;
            scrollH = Screen.bodyHeight-20-height3;
        }
        if(useragent == 'ipad'){
        	$('#smartstream_topic_detail_page_scroll').css('width','666px');
        	$('#smartstream_topic_detail_page_scroll').css('height','300px');
        	$('#smartstream_topic_detail_page_scroll').css('overflow-y','scroll');
        	$('#smartstream_topic_detail_page_scroll').css('overflow-x','hidden');
        }else{
        $('#smartstream_topic_detail_page_scroll').slimScroll({
            width : 666,
            height : scrollH,
            wheelStep : 20,
			disableFadeOut:true
        });
        }
		if(($('#smartstream_topic_detail_page_iframe').css('display') != 'none'));
        var scroller = $('#smartstream_topic_detail_page_scroll');
        scroller.css('height', scrollH);
        scroller.parent().css('height', scrollH);
		if($('#smartstream_topic_detail_page_iframe').css('display') != 'none'){
			 smartstream_topic_detail_page_win.data('kendoWindow').setOptions({height : realH + 2});
		} else {
			 smartstream_topic_detail_page_win.data('kendoWindow').setOptions({height : scrollH + 2});
		}
        smartstream_topic_detail_page_win.data('kendoWindow').center();
        if(useragent != 'ipad'){
        	scroller.slimScroll({});
        }
        var editor = $('#ss_topic_detail_add_comment_editor');
        try{
            editor.data('kendoEditor').refresh();
            editor.data('kendoEditor').focus();
        }catch(e){
        }
        if(useragent == 'ipad'){
        	$('#for_ipad').append('#smartstream_topic_detail_page_iframe{-webkit-overflow-scrolling:touch;overflow-y:scroll;overflow-x:hidden;max-height: 300px}')
        }
    }

    function show_ss_topic_detail_win_with_iframe(source,iframeURL, notID,notType,tagID,creatDate,notText,commentListPageSize, closeCB, showNominateExpert,enablejoin) {
		ss_topic_detail_viewModel.set("hasIFrame",true);
        show_ss_topic_detail_win(source,notID,notType,tagID,creatDate,notText,commentListPageSize, closeCB, showNominateExpert,enablejoin,iframeURL);
        $('#smartstream_topic_detail_page_win_top').hide();
        $('#smartstream_topic_detail_page_iframe').show();
        $('#smartstream_topic_detail_page_iframe_content').attr('src',iframeURL);
    }
	Workport.LocationManager.addURL('smartstreamDetailWindow', detailWindow);
	function detailWindow(params){
		if(params.iframeURL != null)
			show_ss_topic_detail_win_with_iframe(params.source,params.iframeURL,params.notID,params.notType,params.tagID,params.creatDate,params.notText,params.commentListPageSize,params.closeCB,params.showNominateExpert,params.enableJoin);
		else
			show_ss_topic_detail_win(params.source,params.notID,params.notType,params.tagID,params.creatDate,params.notText,params.commentListPageSize,params.closeCB,params.showNominateExpert,params.enableJoin);
	}
	
	function show_ss_topic_detail_win(source,notID,notType,tagID,creatDate,notText,commentListPageSize, closeCB, showNominateExpert,enablejoin,iframeURL){
		//Workport.LocationManager.setFullURL(smartstream_topic_detail_page_win.data('kendoWindow'),'smartstreamDetailWindow',{source:source,notID:notID,notType:notType,tagID:tagID,creatDate:creatDate,notText:notText,commentListPageSize:commentListPageSize,closeCB:closeCB,showNominateExpert:showNominateExpert,enablejoin:enablejoin,iframeURL:iframeURL});
        $('#smartstream_topic_detail_page_win_attachment').hide();
		$('#smartstream_topic_detail_page_iframe').append('<iframe id="smartstream_topic_detail_page_iframe_content" src="" style="width: 666px;height:0px" frameborder="0"></iframe>');
			document.getElementById('smartstream_topic_detail_page_iframe_content').onload = function() {
			updateScrollHeight();
		};
	
        var iframeContent = $('#smartstream_topic_detail_page_iframe_content');
        iframeContent.width(666);
        iframeContent.height(0);
		iframeContent.html("");
        $('#smartstream_topic_detail_page_win').data("kendoWindow").setOptions({
            width : 666
        });
        if(useragent == 'ipad'){
        	$('#smartstream_topic_detail_page_scroll').css('margin-left',0);
        }else{
        	$('#smartstream_topic_detail_page_scroll').parent().css('margin-left',0);
        }
        $('#smartstream_topic_detail_page_win_top').show();
        $('#smartstream_topic_detail_page_iframe').hide();
        ss_topic_detail_comment_next = true;
        ss_topic_detail_notID = notID;
        ss_topic_detail_notType = notType;
        ss_topic_detail_tagID = tagID;
        ss_topic_detail_source = source;
        ss_topic_detail_creatDate = creatDate;
        ss_topic_detail_Text = notText;
        closeCallbackFunction = closeCB;
        showExpert = showNominateExpert;
        enableJoin = enablejoin;
        if (enableJoin) {
            $("#ss_topic_detail_comment_replay_button").addClass("k-state-disabled");
            $("#ss_topic_detail_comment_replay_button").attr("disabled", true);
        }

        ss_topic_detail_viewModel.set("NotificationType",notType);
        if(commentListPageSize){
            ss_topic_detail_viewModel.set("CommentListPageSize",commentListPageSize);
        }else{
            ss_topic_detail_viewModel.set("CommentListPageSize",10);
        }
        //init scroll panel
        updateScrollHeight();
        ss_topic_detail_viewModel.one('init',function(){
                var wp_win = $("#smartstream_topic_detail_page_win").data("kendoWindow");
                wp_win.wrapper.find('.k-i-close').attr("id","ss_topic_detail_win_close_button_1");
                var view_model = this;
                getDetailInfo(this,false,source);
        });
        ss_topic_detail_viewModel.trigger('init');
        if(useragent == 'ipad'){
        	//$('#for_ipad').append('#smartstream_topic_detail_page_win .km-scroll-container{margin-left:0px!important}')
        	$('#smartstream_topic_detail_page_scroll').css('overflow-y','scroll');

        	$("#smartstream_topic_detail_page_scroll").bind("scroll",function(){
	            if ($("#smartstream_topic_detail_page_scroll").scrollTop() == 0) {
	                if (!ss_topic_detail_comment_next) {
	                    return;
	                }
	                ss_topic_detail_comment_next = true;
	                var oldCommentList=ss_topic_detail_viewModel.get("ss_topic_detail_comments_source");
	                if (!oldCommentList || oldCommentList.length <= 0) {
	                    return;
	                }
	                var offsetDate = oldCommentList[oldCommentList.length-1].LastModifiedDate;
	                Workport.Communication.get(Workport.utils.obj2url("Stream/"+ss_topic_detail_viewModel.get("notID")+"/Comment",{ tid: ss_topic_detail_viewModel.get("tagID"), ps: 10, offset:offsetDate, ntype:ss_topic_detail_viewModel.get("notType")}),function(status,result){
						if(result&&result.comments){
							if(result.comments.length>0){
								var newCommentList = [];
								//the old list is not a array. so make it to a new array
								for (var i = 0; i < oldCommentList.length; i ++) {
									newCommentList.push(oldCommentList[i]);
								}
								for (var i = 0; i < result.comments.length; i ++) {
									newCommentList.push(result.comments[i]);
								}
								ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",addCommentListTimeStamp(newCommentList));
							}
							if ( result.ResponseCode == 'WP1005') {
								ss_topic_detail_comment_next = false;
							} else {
								ss_topic_detail_comment_next = true;
							}
						}else{
							ss_topic_detail_comment_next = true;
						}
					});
	            }
	        });
        }else{
        $('#smartstream_topic_detail_page_scroll').slimScroll().bind('slimscroll', function(e, pos) {
            if (pos == 'bottom') {
                if (!ss_topic_detail_comment_next) {
                    return;
                }
                ss_topic_detail_comment_next = true;
                var oldCommentList=ss_topic_detail_viewModel.get("ss_topic_detail_comments_source");
                if (!oldCommentList || oldCommentList.length <= 0) {
                    return;
                }
                var offsetDate = oldCommentList[oldCommentList.length-1].LastModifiedDate;
                Workport.Communication.get(Workport.utils.obj2url("Stream/"+ss_topic_detail_viewModel.get("notID")+"/Comment",{ tid: ss_topic_detail_viewModel.get("tagID"), ps: 10, offset:offsetDate, ntype:ss_topic_detail_viewModel.get("notType")}),function(status,result){
					if(result&&result.comments){
						if(result.comments.length>0){
							var newCommentList = [];
							//the old list is not a array. so make it to a new array
							for (var i = 0; i < oldCommentList.length; i ++) {
								newCommentList.push(oldCommentList[i]);
							}
							for (var i = 0; i < result.comments.length; i ++) {
								newCommentList.push(result.comments[i]);
							}
							ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",addCommentListTimeStamp(newCommentList));
						}
						if ( result.ResponseCode == 'WP1005') {
							ss_topic_detail_comment_next = false;
						} else {
							ss_topic_detail_comment_next = true;
						}
					}else{
						ss_topic_detail_comment_next = true;
					}
				});
            }
        });
        }

		var ss_topic_detail_add_comment = $('#ss_topic_detail_add_comment');
		ss_topic_detail_add_comment.on("click",function(e){
			if (enableJoin) {
				$("#ss_topic_detail_comment_replay_button").addClass("k-state-disabled");
				$("#ss_topic_detail_comment_replay_button").attr("disabled", true);
			} else {
				$("#ss_topic_detail_comment_replay_button").removeClass("k-state-disabled");
				$("#ss_topic_detail_comment_replay_button").attr("disabled", false);
			}
			ss_topic_detail_add_comment.hide();
			$('.ss_topic_detail_white_hr').removeClass('wp_mb_10');
			$('#ss_topic_detail_comment').show();
			$("#ss_topic_detail_add_comment_editor").data("kendoEditor").focus();
			ssdClearAttchmentView();
			
			$("#ss_topic_detail_select_file_field").kendoUpload({
				localization: {
					select: "Browse"
				},
				select: function(e) {
					var fileType;
					var alertMsg;
					$('#ss_topic_detail_select_file_name').val('');
					$("#ss_topic_detail_select_file_btn_attach").addClass("k-state-disabled");
					ssd_ShareWinFileAppointType.indexOf("jpg") > -1 ? fileType = 0 : fileType = 1;
					fileType == 0 ? alertMsg = "The image must be of type bmp, gif, jpeg, png, tiff" : alertMsg = "The file must be of type doc, docx, pdf, ppt, pptx, txt, xls, xlsx, zip";
					//add alert id
					$('#global_alert_win').find('p').attr("id","smartstream_upload_file_type_error");
					$('#global_alert_win').find('span.yes').attr("id","smartstream_upload_file_type_error_ok_button");
					var specialChar = ["\\","~","#", "%", "&", "*", ":","\"", "<", ">", "?", "/", "{", "|", "}"]
					for (var i = 0; i < specialChar.length; i++) {
						if (e.files[0].name.indexOf(specialChar[i]) > -1) {
							Workport.utils.alertMsg("", 'The attachment name cannot contain any of the following special characters: "\\ ~ # % & * : \" < > ? / { | }" . Please rename and try again.', function(_data){});
							e.preventDefault();
							return;
						}
					}
					//Check the file type
					if (ssd_ShareWinFileAppointType.indexOf(e.files[0].extension.toLowerCase().substring(1)) < 0) {
						Workport.utils.alertMsg("", alertMsg, function(_data){});
						e.preventDefault();
						return;
					}
					// Check file size < 50MB
					if (e.files[0].size > (50 * 1024 * 1024)) {
						fileType == 0 ? Workport.utils.alertMsg("", "The size of the image must be within <50 MB>.", function(_data){}) : Workport.utils.alertMsg("", "The size of the attachment must be within <50 MB> .", function(_data){});
						e.preventDefault();
						return;
					}
					// Check file count < 5
					var fileCount = 0;
					for (var i = 0; i < ssd_SelectedFileName.length; i++) {
						if (fileType == 0 && ssd_SelectedFileName[i].type.match(/image.*/)) {
							fileCount = fileCount + 1;
						} else if (fileType == 1 && !ssd_SelectedFileName[i].type.match(/image.*/)) {
							fileCount = fileCount + 1;
						}

						if (e.files[0].name== ssd_SelectedFileName[i].name) {
							Workport.utils.alertMsg("", "An attachment with the same name already exists. Please rename the attachment and try again.", function(_data){});
							e.preventDefault();
							return;
						}
					}
					if (fileCount >= 5) {
						fileType == 0 ? Workport.utils.alertMsg("", "You can only select five Image files!", function(_data){}) : Workport.utils.alertMsg("", "You can only select five documents!", function(_data){});
						e.preventDefault();
						return;
					}
					// $("#ss_topic_detail_select_file ul li:last").hide();
					$('#ss_topic_detail_select_file_name').val(e.files[0].name);

					if ($("#ss_topic_detail_select_file"+" ul li:last").is(':hidden')) {
						//$("#ss_topic_detail_select_file_field").closest('td').find('ul').remove();
					}
					$("#ss_topic_detail_select_file_btn_attach").removeClass("k-state-disabled");
			},
			remove: function(e) {
				for (var i = 0; i < ssd_SelectedFileName.length; i++ ) {
					if (ssd_SelectedFileName[i].name == e.files[0].name) {
						ssd_SelectedFileName.splice(i, 1);
				ssd_SelectedFileContents.splice(i, 1);
					}
				}
				if ($("#ss_topic_detail_select_file div:eq(1)").hasClass("k-upload-button-disable")) {
					$('#ss_topic_detail_select_file').find('input:file:last').prop('disabled', false);
					$("#ss_topic_detail_select_file input:file:last").css("cursor","pointer");
					$("#ss_topic_detail_select_file div:eq(1)").removeClass("k-upload-button-disable");
				}
				if (ssd_SelectedFileName.length == 0) {
					$("#ss_topic_detail_select_file ul").css("display", 'none');
					updateScrollHeight();
				}
			}
			
		});
		$('#ss_topic_detail_select_file_name').val("");
		$('.k-upload-files').hide();
		$('.k-files').hide();
		if($("#ss_topic_detail_select_file_name").length == 0 ){
			var _place_holder = $('#ss_topic_detail_select_file').find('td:first>div');
			var _input_for_text = '<input type="text" id="ss_topic_detail_select_file_name" style="float:left;" class="k-textbox wp_fz_12 wp_mt_0 wp_w_510" disabled="true" >';
			$(_input_for_text).insertBefore(_place_holder);
		}
		$('#ss_topic_detail_select_file_name').val("");
		$('.k-upload-files').hide();
		$('.k-files').hide();
		updateScrollHeight();
		$("#ss_topic_detail_comment").find(".k-editable-area").find("iframe").attr("id","smartstream_detail_window_RTE_frame");
		if(ss_topic_detail_notType == 'U'){
			Workport.AtWho.atKendoEditor($("#ss_topic_detail_add_comment_editor").data("kendoEditor"), 'U');
		} else {
			_loader = new Workport.Loader($('#ss_topic_detail_comments'),{position:'center',imgCSS:{'margin-top': '0px'},text:'Loading',imgColor:'black',hasMask:false,textCSS:{'color':'black'}});
			_loader.show();
			Workport.StreamAPI.getMentionUsers(function(_d,_c){
				_loader.hide();
				WP_MENTION_COMM = _d.Users;
				Workport.AtWho.atKendoEditor($("#ss_topic_detail_add_comment_editor").data("kendoEditor"), 'C');
			},{targetID: ss_topic_detail_tagID,type:"C"});
		}
	});
		if(ss_topic_detail_viewModel.get("hasIFrame")){
			$('#smartstream_topic_detail_page_win_attachment').show();
		}
		ss_topic_detail_viewModel.set("hasIFrame",false);
	}

	function ssdClearAttchmentView()
	{
        var shareWinDelFileSize =$("#ss_topic_detail_select_file_table ul li").size();
        while (shareWinDelFileSize > 0) {
            shareWinDelFileSize--;
            $("#ss_topic_detail_select_file ul li:eq(" + shareWinDelFileSize + ")").remove();
        }
        $('#ss_topic_detail_select_file_name').hide();
        $('#ss_topic_detail_select_file_table').hide();
        if ($($("#ss_topic_detail_bottom_icon_expand").find("i")[0]).hasClass("header_win_e_10_10")) {
            $($("#ss_topic_detail_bottom_icon_expand").find("i")[0]).toggleClass("main_calendar_k_10_10 header_win_e_10_10");
            $($("#ss_topic_detail_bottom_icon_expand").find("a")[0]).toggleClass("ss_share_win_detail_arrow ss_topic_detail_hand");
        }
        if ($($("#ss_topic_detail_bottom_icon_expand").find("i")[1]).hasClass("header_win_f_10_10")) {
            $($("#ss_topic_detail_bottom_icon_expand").find("i")[1]).toggleClass("main_calendar_m_8_10 header_win_f_10_10");
            $($("#ss_topic_detail_bottom_icon_expand").find("a")[1]).toggleClass("ss_share_win_detail_arrow ss_topic_detail_hand");
        }
        if ($(".k-upload-sync").hasClass("k-state-doors")) {
            $(".k-upload-sync").removeClass("k-state-doors");
            $('.k-upload-sync').find('input:file:last').prop('disabled', false);
            $(".k-upload-button>input").css("cursor","pointer");
            $("#ss_topic_detail_select_file_btn_attach").removeClass("k-state-disabled");
        }
        ssd_SelectedFileName = [];
        ssd_SelectedFileContents = [];
        $("#ss_topic_detail_select_file_btn_attach").addClass("k-state-disabled");

        if ($("#ss_topic_detail_select_file div:eq(1)").hasClass("k-upload-button-disable")) {
            $('#ss_topic_detail_select_file').find('input:file:last').prop('disabled', false);
            $("#ss_topic_detail_select_file>input").css("cursor","pointer");
            $("#ss_topic_detail_select_file div:eq(1)").removeClass("k-upload-button-disable");
        }
	}

	function addCommentListTimeStamp(commentList){
		for(var i=0;i<commentList.length;i++){
			var comment=commentList[i];
			var date="";
			var dtServerDate = new Date(comment.ServerDate);
        	var dtLastModifiedDate = new Date(comment.LastModifiedDate);
        	var iDay = ss_GetDateDiff(dtLastModifiedDate,dtServerDate,"day");
        	var iHour;
        	var iMinutes;
        	var iSeconds;
        	if(iDay==0){
        		iHour=ss_GetDateDiff(dtLastModifiedDate,dtServerDate,"hour");
        		if(iHour==0){
        			iMinutes=ss_GetDateDiff(dtLastModifiedDate,dtServerDate,"minute");
        			if(iMinutes==0){
        				iSeconds=ss_GetDateDiff(dtLastModifiedDate,dtServerDate,"second");
        				if(iSeconds<1) iSeconds= 1;
        				date=iSeconds+" second(s) ago";
        			}else{
        				date=iMinutes+" minute(s) ago";
        			}
        		}else{
        			date=iHour+" hour(s) ago";
        		}
        	}else{
        		date=iDay+" day(s) ago";
        	}
        	commentList[i].date=date;//ss_calDays(comment.CreatedDate,comment.LastModifiedDate);
		}
		return commentList;
	}

	function ss_topic_detail_get_recent_users(data){
		var recent_users=new Array();
		if(data.length>0){
			if(data[0].LikedUsersDetails&&data[0].LikedUsersDetails.length>0){
				$('#ss_topic_detail_win_like_users_left_div').show();
				for(var j=0;j<data[0].LikedUsersDetails.length;j++){
					if(j<3&&j!=(data[0].LikedUsersDetails.length-1)){
						recent_users.push({"username":data[0].LikedUsersDetails[j].UserName,"split":", ",UserID:data[0].LikedUsersDetails[j].UserID});
					}else{
						recent_users.push({"username":data[0].LikedUsersDetails[j].UserName,"split":"",UserID:data[0].LikedUsersDetails[j].UserID});
					}
				}
			}else{
				$('#ss_topic_detail_win_like_users_left_div').hide();
			}
		}
		return recent_users;
	}

	function ss_topic_detail_like_notification_callback(currentTarget) {
		var flag=ss_topic_detail_viewModel.get("isLiked");
		var likeCount = 0;
		if(!flag){
			likeCount=parseInt(ss_topic_detail_viewModel.get("ss_topic_detail_LikeCount"))+1;
			ss_topic_detail_viewModel.set("ss_topic_detail_like_title","You have Liked this");
			currentTarget.removeClass("main_smartstream_w_8_8");
			currentTarget.addClass("main_smartstream_t_8_8");
			ss_topic_detail_viewModel.set("ss_topic_detail_like_icon","main_smartstream_t_8_8");
			ss_topic_detail_viewModel.set("isLiked",true);
		} else {
			likeCount=parseInt(ss_topic_detail_viewModel.get("ss_topic_detail_LikeCount"))-1;
			ss_topic_detail_viewModel.set("ss_topic_detail_like_title","Like this");
			currentTarget.removeClass("main_smartstream_t_8_8");
			currentTarget.addClass("main_smartstream_w_8_8");
			ss_topic_detail_viewModel.set("isLiked",false);
			ss_topic_detail_viewModel.set("ss_topic_detail_like_icon","main_smartstream_w_8_8");
			if(likeCount != 0)
				ss_topic_detail_viewModel.set("isHasHandClass","ss_topic_detail_hand");
			else	
				ss_topic_detail_viewModel.set("isHasHandClass","");
		}
		ss_topic_detail_viewModel.set("ss_topic_detail_LikeCount",likeCount);
		
		getLikeUserInfo(ss_topic_detail_notID);
	}

	function ss_topic_detail_like_comment_callback(currentTarget) {
		var _self = this;
 		Workport.Communication.get(Workport.utils.obj2url("Stream/"+ss_topic_detail_viewModel.get("notID")+"/Comment",{ tid: ss_topic_detail_viewModel.get("tagID"), ps: 200, offset:"",ntype:ss_topic_detail_viewModel.get("notType")}),function(status,result){
			_self.isLiked = false;
			if(result&&result.comments){
			    ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",addCommentListTimeStamp(result.comments));
		    }else{
		    	ss_topic_detail_viewModel.set("ss_topic_detail_comments_source",[]);
		    	//Workport.utils.alertMsg("", "Comment List is Null.");
		    }
		});
	}

	function ss_topic_detail_handle_attachment_url(attachmentArr){
		var result_arr=new Array();
		var attachment_obj;
		//sslog(attachmentArr);
		for (var i =0;i<attachmentArr.length;i++)
		{
			attachment_obj=new Object();
			attachment_obj.url=attachmentArr[i].RefURL;
			attachment_obj.name=attachmentArr[i].Name;
			attachment_obj.type=attachmentArr[i].Type;
			attachment_obj.shortname=attachment_obj.name;
			var type=attachmentArr[i].Type;//ss_topic_detail_get_attachment_type_by_url(attachmentArr[i]);
			if(type=="docx"||type=="doc"){
				attachment_obj.typeIcon="main_documents_e_20_20";
			}else if(type=="tiff" || type == "tif"){
				attachment_obj.typeIcon="main_documents_t_20_20";
			}else if(type=="pdf"){
				attachment_obj.typeIcon="main_documents_f_20_20";
			}else if(type=="xlsx"||type=="xls"){
				attachment_obj.typeIcon="main_documents_o_20_20";
			}else if(type=="ppt"||type=="pptx"){
				attachment_obj.typeIcon="main_big_k_20_20";
			}else if(type=="txt"){
				attachment_obj.typeIcon="main_big_n_20_20";
			}else if(type=="zip"){
				attachment_obj.typeIcon="main_big_m_20_20";
			}else{
				attachment_obj.typeIcon="main_documents_e_20_20";
			}
			result_arr.push(attachment_obj);
		}
		return result_arr;
	}

	function ss_topic_detail_get_attachment_name_by_url(url){
   			return url=url.replace(/(.*\/){0,}([^\.]+).*/ig,"$2");
	}

	function ss_topic_detail_get_attachment_type_by_url(url){
 			return url = url.substr(url.lastIndexOf(".")+1);
	}

	function ss_GetDateDiff(startTime, endTime, diffType) {
	    diffType = diffType.toLowerCase();
	    var divNum = 1;
	    switch (diffType) {
	        case "second":
	            divNum = 1000;
	            break;
	        case "minute":
	            divNum = 1000 * 60;
	            break;
	        case "hour":
	            divNum = 1000 * 3600;
	            break;
	        case "day":
	            divNum = 1000 * 3600 * 24;
	            break;
	        default:
	            break;
	    }
	    return parseInt(Math.abs((endTime.getTime() - startTime.getTime()) / parseInt(divNum)));
	}

	function ss_tipic_detailGetImgUrl(imgsList){
		var result=new Array();
		var img_obj;
		for (var i=0;i<imgsList.length;i++)
		{
			img_obj=new Object();
			var img=imgsList[i].RefURL.split("*");
			img_obj.smallurl=img[1];
			img_obj.bigurl=img[0];
			var img_name=imgsList[i].Name;//ss_topic_detail_get_attachment_name_by_url(img_obj.bigurl);
			img_obj.name=img_name;
			img_obj.type=imgsList[i].Type;
			img_obj.shortname=img_obj.name;
			result.push(img_obj);
		}
		return result;
	}
	
	function onTagClick(){
		if(ss_topic_detail_source == 'smartstream'){
			if($('#smartstream_min_view').is(":visible")){
				HomePage_Scrollable.zoom(WPMoudleManager.getModule('smartstream').index);
			}
			smartstream.onTagsClick(ss_topic_detail_viewModel.get("ss_topic_detail_Tags"));
		} else if (ss_topic_detail_source == 'community'){
			community_smartstream.onTagsClick(ss_topic_detail_viewModel.get("ss_topic_detail_Tags"));
		} else if (ss_topic_detail_source == 'profile'){
			homepageProfileWin.onTagsClick(ss_topic_detail_viewModel.get("ss_topic_detail_Tags"));
		} else if (ss_topic_detail_source == 'globalsearch'){
			homepageSearchWin.open(ss_topic_detail_viewModel.get("ss_topic_detail_Tags"));
		}
		smartstream_topic_detail_page_win.data("kendoWindow").close();
	}

	function postLikeMessage(putdata ,callback,currentTarget){
		if(this.isLiked)
			return;
		this.isLiked = true;
		Workport.Communication.post('Stream/Like',function(status,result){	
			if(result&&result.ResponseCode&&result.ResponseMessage){
				if(result.ResponseCode!="WP1016"){
	   				callback(currentTarget);
		   		}else{
		   			Workport.utils.alertMsg("", result.ResponseMessage, function(_data){});
		   		}
			}else{
				Workport.utils.alertMsg("", "Click like's response is Null.", function(_data){});
			}
		},putdata);
	}
</script>